//
//  DocotorDescribeCell.m
//  QuickCure
//
//  Created by Ruihaha on 16/9/12.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "DocotorDescribeCell.h"
#import <UIImageView+WebCache.h>


@interface DocotorDescribeCell ()

@property(nonatomic,strong)UIImageView * icon;
@property(nonatomic,strong)UILabel * nameLabel;
@property(nonatomic,strong)UILabel * professional;
@property(nonatomic,strong)UILabel * hospital;
@property(nonatomic,strong)UIButton * order;
@property(nonatomic,strong)UIButton*  flower;
@property(nonatomic,strong)UIButton * flag;


@property(nonatomic,strong)UIButton * macthInfo;


@end

@implementation DocotorDescribeCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        //创建医生头像
        self.icon = [[UIImageView alloc]init];
        [self.contentView addSubview:self.icon];
       

        //医生姓名
        self.nameLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.nameLabel];
        
        //医生职称
        self.professional = [[UILabel alloc]init];
        [self.contentView addSubview:self.professional];
   
        
        
        //所在医院
        self.hospital = [[UILabel alloc]init];
        [self.contentView addSubview:self.hospital];
       
        
        
        //预约icon
        self.order = [[UIButton alloc]init];
        [self.contentView addSubview:self.order];
 
        //鲜花icon
        self.flower = [[UIButton alloc]init];
        [self.contentView addSubview:self.flower];
        
        
        //锦旗icon
        self.flag = [[UIButton alloc]init];
        [self.contentView addSubview:self.flag];
        
        

        //预约icon
        self.macthInfo = [[UIButton alloc]init];
        self.macthInfo.userInteractionEnabled=NO;
        [self.contentView addSubview:self.macthInfo];
       


    }
    return self;
}

-(void)setModel:(DoctorModel *)model{
    
    _model=model;
    //头像
    
    if (model.doctor_portrait!=nil) {
        
        [self.icon sd_setImageWithURL:[NSURL URLWithString:model.doctor_portrait]];
    }else{
        self.icon.image = [UIImage imageNamed:@"illness_img_person.png"];
    }

     self.icon.layer.cornerRadius=35;
    self.icon.clipsToBounds=YES;
    [self.icon makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(15);
        make.size.equalTo(70);
        make.bottom.equalTo(self.contentView).offset(-15);
    }];

    //名字
    self.nameLabel.text = model.doctor_name;
    self.nameLabel.font=[UIFont systemFontOfSize:16];
    self.nameLabel.textColor=[UIColor blackColor];
    self.nameLabel.numberOfLines=0;
    self.nameLabel.textAlignment=NSTextAlignmentLeft;
    [self.nameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.icon.mas_right).offset(20);
        make.top.equalTo(self.contentView).offset(20);
        
    }];
    

    //职称
    if ([model.doctor_title_name isEqualToString:@"其他"]) {
        self.professional.text = @"主治医师";
    }else{
        self.professional.text = model.doctor_title_name;

    }
    self.professional.font=[UIFont systemFontOfSize:16];
    self.professional.textColor=[UIColor lightGrayColor];
    self.professional.numberOfLines=0;
    self.professional.textAlignment=NSTextAlignmentLeft;
    [self.professional makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.mas_right).offset(10);
        make.top.equalTo(self.contentView).offset(20);
        
    }];
    
    //医院
    self.hospital.text = model.doctor_hospital_name;
    self.hospital.font=[UIFont systemFontOfSize:16];
    self.hospital.textColor=[UIColor lightGrayColor];
    self.hospital.numberOfLines=0;
    self.hospital.textAlignment=NSTextAlignmentLeft;
    [self.hospital makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.icon.mas_right).offset(20);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(5);
        
    }];
    
    //预约
    [self.order setImage:[UIImage imageNamed:@"yuyueliang"] forState:UIControlStateNormal];
    [self.order setTitle:[NSString stringWithFormat:@"%d",[model.operation_count intValue]]  forState:UIControlStateNormal];
    [self.order setTitleColor:kThemeColor forState:UIControlStateNormal];
    [self.order.titleLabel setFont:[UIFont systemFontOfSize:14]];
    [self.order makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.hospital.mas_bottom).offset(10);
        make.left.equalTo(self.icon.mas_right).offset(20);
    }];

    //鲜花
    [self.flower setImage:[UIImage imageNamed:@"xianhua"] forState:UIControlStateNormal];
    [self.flower setTitle:[NSString stringWithFormat:@"%d",[model.flower intValue]] forState:UIControlStateNormal];
    [self.flower setTitleColor:kThemeColor forState:UIControlStateNormal];
    [self.flower.titleLabel setFont:[UIFont systemFontOfSize:14]];
    [self.flower makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.hospital.mas_bottom).offset(10);
        make.left.equalTo(self.order.mas_right).offset(20);
    }];
    
    //锦旗
    [self.flag setImage:[UIImage imageNamed:@"jinqi"] forState:UIControlStateNormal];
    [self.flag setTitle:[NSString stringWithFormat:@"%d",[model.banner intValue]] forState:UIControlStateNormal];
    [self.flag setTitleColor:kThemeColor forState:UIControlStateNormal];
    [self.flag.titleLabel setFont:[UIFont systemFontOfSize:14]];
    [self.flag makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.hospital.mas_bottom).offset(10);
        make.left.equalTo(self.flower.mas_right).offset(20);
    }];
    
    //匹配
    [self.macthInfo setBackgroundImage:[UIImage imageNamed:@"pipeidu"] forState:UIControlStateNormal];
    [self.macthInfo setTitle:[NSString stringWithFormat:@"匹配度:%@",model.accuracy] forState:UIControlStateNormal];
    [self.macthInfo setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.macthInfo.titleLabel.numberOfLines=0;
    self.macthInfo.titleLabel.textAlignment=NSTextAlignmentCenter;
    [self.macthInfo.titleLabel setFont:[UIFont systemFontOfSize:12]];
    [self.macthInfo makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(-10);
        make.right.equalTo(self.contentView).offset(-30);
        make.size.equalTo(CGSizeMake(40, 70));
        
    }];
}
@end
